//
// Created by Administrator on 2023/9/29.
//  链表 删除数据
//

#include <iostream>

using namespace std;
struct Node
{
    int value;
    Node *next;
    // 构造函数
    Node (int v,Node *n= nullptr)
    {
        value=v;
        next=n;
    }
    Node()
    {
        value=0;
        next=nullptr;
    }
};

int main()
{
    int arr[9]={1,2,3,4,5,6,7,8,9};
    Node *head=new Node();
    Node *cur =head;
    // arr to linked list
    for (int i : arr)
    {
        Node *t = new Node(i);
//        t->value=i;
//        t->next= nullptr;
        cur->next=t;
        cur=cur->next;
    }
    // insert a item
    // 把第local个删除
    int local = 4;
    cur=head;
    for (int j = 1; j < local; ++j)
    {
        cur=cur->next;
    }
    cout<<cur->value<<endl;
    cur->next=cur->next->next;
    // print linked list
    cur=head->next;
    while(cur!=nullptr)
    {
        cout<<cur->value<<" ";
        cur=cur->next;
    }
    return 0;
}